package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.model.product.CategoryTrademarkVo;
import com.atguigu.gmall.product.service.BaseCategoryTrademarkService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//分类品牌列表
@Api(value = "分类和品牌接口")
@RestController
@RequestMapping("/admin/product/baseCategoryTrademark")
public class BaseCategoryTrademarkController {

    @Autowired
    private BaseCategoryTrademarkService baseCategoryTrademarkService;

    //admin/product/baseCategoryTrademark/findTrademarkList/{category3Id}
    //根据Category3Id获取品牌的列表
    @GetMapping("findTrademarkList/{category3Id}")
    public Result findTrademarkList(@PathVariable Long category3Id) {
        List<BaseTrademark> findTrademarkList = baseCategoryTrademarkService.findTrademarkList(category3Id);
        return Result.ok(findTrademarkList);
    }

    //admin/product/baseCategoryTrademark/findCurrentTrademarkList/{category3Id}
//    根据category3Id获取可选品牌列表
    @GetMapping("findCurrentTrademarkList/{category3Id}")
    public Result findCurrentTrademarkList(@PathVariable Long category3Id) {
        List<BaseTrademark> findCurrentTrademarkList =
                baseCategoryTrademarkService.findCurrentTrademarkList(category3Id);

        return Result.ok(findCurrentTrademarkList);
    }

    //保存新增
    @PostMapping("save")
    public Result save(@RequestBody CategoryTrademarkVo categoryTrademarkVo) {
        baseCategoryTrademarkService.saveCategoryTrademark(categoryTrademarkVo);
        return Result.ok();
    }
// 删除实现  remove/{category3Id}/{trademarkId}
    @DeleteMapping("remove/{category3Id}/{trademarkId}")
    public  Result remove11(@PathVariable Long category3Id,
                          @PathVariable Long trademarkId){
        baseCategoryTrademarkService.remove11(category3Id,trademarkId);
        return Result.ok();
    }
}
